<template>
	<view class="container">
		<view class="box1">
			<text>NO.{{cardNum}}</text>
		</view>
		<view class="QR_code">
			<!-- <uqrcode ref="uqrcode" canvas-id="qrcode" :value="cardNo">
			</uqrcode> -->
			<view id="guestQrcode" style="text-align: center;"></view>
		</view>
		<view class="flx" @click="refreash">
			<image class="refreshImg" src="../../static/images/refresh.png" mode=""></image>
			<!-- <view class="time">66秒</view> -->
			<view class="txt">点击刷新</view>
		</view>

		<view class="note">
			注意事项：
			<view class="txt1">
				<!-- <view class="">1.二维码有效期为80秒，截图无效;</view> -->
				<view class="" style="margin-bottom: 20rpx;">1.到达网点出示您的二维码给网点工作人员,工作人员扫描您的二维码,填写回收信息即可完成交易。</view>
				
				<view class="">2.交易完成后系统自动将等价值的积分计入您的个人账户。</view>
			</view>
		</view>
	</view>
</template>

<script>
	// import UQRCode from 'uqrcodejs';
	import QRCode from "qrcodejs2";
	// import UQRCode from '@uqrcode/js'; // npm install @uqrcode/js
	export default {
		data() {
			return {
				cardNo: '11100035871',
				cardNum: ''
			}
		},
		methods: {
			initQR() {
				let proportionUpdate = document.getElementById('guestQrcode');
				if (proportionUpdate) {
					proportionUpdate.innerHTML = ""
				}
				this.$nextTick(() => {
					setTimeout(() => {
						var qrcode = new QRCode(document.getElementById('guestQrcode'), {
							width: 203,
							height: 203
						});
						qrcode.clear(); // 清除代码
						qrcode.makeCode(this.cardNo); // 生成另外一个二维码
					}, 500)
				})
			},
			refreash() {
				this.initQR()
			}
		},
		onLoad() {
			// 设置导航栏的颜色和标题颜色
			uni.setNavigationBarColor({
				frontColor: "#ffffff", //文字颜色
				backgroundColor: "rgb(79,172,252)" //底部背景色
			})
			// uni.setStorageSync('cardNo',11100035871);
			const cardNOValue = uni.getStorageSync('cardNo')
			this.cardNum = cardNOValue
			console.log(cardNOValue, 'cardNOValue')
			if (cardNOValue) {
				this.cardNo = '91' + cardNOValue
			}
			console.log(this.cardNo, 'this.cardNo')
			this.initQR()
		},


	}
</script>

<style lang="less" scoped>
	page {
		
		background: linear-gradient(to bottom,var(--global-bg-color), var(--global-bg-color));
	}

	.container {
		width: 702rpx;
		height: 1424rpx;
		background: #FFFFFF;
		border-radius: 15rpx 15rpx 0rpx 0rpx;
		margin: 24rpx auto 0;
		padding-top: 92rpx;
	}

	.box1 {
		width: 440rpx;
		height: 100rpx;
		font-family: Source Han Sans SC;
		font-weight: 500;
		font-size: 36rpx;
		color: #000000;
		line-height: 34rpx;
		border: 1rpx solid #999;
		border-radius: 10rpx;
		line-height: 100rpx;
		text-align: center;
		margin: 0rpx auto;
	}

	.box1 text {
		color: var(--global-bg-color);
		margin-left: 40rpx;
	}

	.QR_code {
		width: 406rpx;
		height: 406rpx;
		margin: 0rpx auto;
		margin-top: 92rpx;
		margin-bottom: 20rpx;
	}

	.flx {
		display: flex;
		justify-content: center;
		align-items: center;
		font-family: Source Han Sans SC;
		font-weight: 400;
		font-size: 28rpx;
		color: #666;
		line-height: 34rpx;
        text-align: center;
		.refreshImg {
			width: 32rpx;
			height: 27rpx;
		}

		.time {
			color: #3EAAFB;
			margin: 0 15rpx;
		}

		.txt {
			padding-left: 15rpx;
		}
	}

	.note {
		font-family: Source Han Sans SC;
		font-weight: 500;
		font-size: 28rpx;
		color: #000000;
		line-height: 34rpx;
		margin: 92rpx 0 0 30rpx;

		.txt1 {
			line-height: 42rpx;
			margin-top: 30rpx;
		}
	}
</style>